from django.db import models
from django.utils.timezone import now

from app.models import FMUser, ProductSpec


class PreOrder(models.Model):
    user = models.ForeignKey(FMUser, on_delete=models.CASCADE)
    created_time = models.DateTimeField(default=now)


class PreOrderSpec(models.Model):
    spec = models.ForeignKey(ProductSpec, on_delete=models.CASCADE)
    pre_order = models.ForeignKey(PreOrder, related_name='specs', on_delete=models.CASCADE)
    amount = models.PositiveIntegerField()
